package com.example.xinlijiankangsys.service;

import com.example.xinlijiankangsys.mapper.CommentMapper;
import com.example.xinlijiankangsys.pojo.Comment;
import com.example.xinlijiankangsys.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentMapper commentMapper;

    @Override
    @Transactional
    public Comment create(Comment comment) {
        commentMapper.insert(comment);
        return comment;
    }

    @Override
    @Transactional
    public void like(Long commentId) {
        commentMapper.incrementLikeCount(commentId);
    }

    @Override
    @Transactional
    public void delete(Long commentId) {
        commentMapper.deleteById(commentId);
    }
}